﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.IO;

using Consejo.Monitoring.BusinessObjects;

namespace Consejo.Monitoring.Destinations
{
    public class CSVLog : IMonitorDestination
    {

        #region IMonitorDestination Members

        public bool SendStatus(Consejo.Monitoring.BusinessObjects.SystemStatus _status)
        {
            foreach (ServerStatus _server in _status.Servers)
            {
                WriteLogEntry(_server);
            }
        }

        #endregion

        #region File System Operations

        private void WriteLogEntry(ServerStatus _serverStatus)
        {
            string _logFile = GetCurrentLogFile();

            foreach (IStatusItem _statusItem in _serverStatus.StatusItems)
            {
                
            }

        }

        private StreamWriter GetCurrentLogFile()
        {
            string _logPath = ConfigurationSettings.AppSettings["LogFilePath"] + "WinMontitorLog-" + DateTime.Now.ToString("yyyy-MM-dd") + ".csv";
            StreamWriter _stream;
            if (!File.Exists(_logPath))
            {
                _stream = File.CreateText(_logPath);
                
            }
            

        }

        #endregion
    }
}
